home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 May / PCPlus May 1998=disk A.iso / trial / gdldb / disk1 / data1.cab / Example_Files / script.scp < prev    next >
Encoding:
Text File  |  1998-01-21  |  6.6 KB  |  261 lines

  1. ##########################################################
  2. # GDIdB demo script (c) 1997 Global Data Industries
  3. # Datasource=workweb.mdb (Access database)
  4. #
  5. # In this advanced example, the script creates a top-level
  6. # page from the contents of the categories table of the
  7. # database, with links to a series of pages listing the
  8. # headings of the jobs stored under each category.
  9. # Each of the job headings are hyperlinked to a html document
  10. # containing the actual job description.
  11. ##########################################################
  12.  
  13. # Print the information screen
  14.  
  15. &cls
  16. &print("WorkWeb Demo Script")
  17. &print("---------------------------------")
  18.  
  19.  
  20. # Name the ODBC datasource to be used.
  21.  
  22. &datasource("Driver={Microsoft Access Driver (*.mdb)};DBQ=workweb.mdb")
  23.  
  24.  
  25. ##########################################################
  26. # Generate the top-level HTML file. 
  27.  
  28. &html("index.html")
  29. {
  30.     <HTML>
  31.     <HEAD>
  32.     <TITLE>Work Web</TITLE>
  33.     </HEAD>
  34.     <BODY BACKGROUND="wwbg1.gif" LINK=BLACK VLINK=BLACK ALINK=WHITE>
  35.     <FONT FACE="Verdana,Helvetica">
  36.     <IMG SRC="ww1.gif">
  37.     <BR><BR><BR><BR><BR><BR>
  38.     <TABLE CELLPADDING=10 CELLSPACING=10 BORDER=0 WIDTH="100%">
  39.     <TR>
  40.     <TD VALIGN=TOP>
  41.     <FONT FACE="Verdana,Helvetica">
  42.     <FONT SIZE="+2">Select a Job Category:</FONT>
  43.     <BR><BR>
  44.  
  45.     # this SQL statement retrieves all of the jobs in the database.
  46.     # the only reason it does this is so that the ?recordsetsize?
  47.     # variable will contain the total number of jobs in the database.
  48.  
  49.     &sql("SELECT * FROM Jobs")
  50.     {
  51.         The Job database currently contains ?recordsetsize?
  52.         vacancies.<BR><BR>
  53.         <FONT SIZE="-1">
  54.         (Updated from database on ?gdidbdate? at ?gdidbtime?)
  55.         </FONT>
  56.         <BR><BR>
  57.     }
  58.     <UL>
  59.  
  60.  
  61.     # loop through each of the categories, creating category
  62.     # pages (by calling subroutine "jobcategory") and
  63.     # links to them from this page.
  64.  
  65.     &getdata("SELECT * FROM Categories")
  66.     {
  67.         &print("Generating category ?JobCategory?")
  68.         &sql("SELECT * FROM Jobs WHERE (((Jobs.JCatKey)=?JobcatKey?))")
  69.         {
  70.             # do the hyperlink to the job category page
  71.             <FONT SIZE="-2">(?recordsetsize?)</FONT> <A HREF="cat?rownumber[-1]?.html" onMouseover="window.status='View Jobs in category ?JobCategory[-1]?';return true">?JobCategory[-1]?</A><BR>
  72.  
  73.             # followed by the file to link to
  74.             # (created by subroutine jobcategory)
  75.             &jobcategory
  76.         }
  77.     }
  78.     </UL>
  79.     </FONT>
  80.     </TD>
  81.     <TD WIDTH="45%" VALIGN=TOP><FONT FACE="Verdana,Helvetica">
  82.     <B>This Site</B>  demonstrates the use of GDI's Database
  83.     publishing software. A relational database consisting of
  84.     jobs grouped by job category is merged with the web site
  85.     HTML and passed to the web server <I>automatically.</I> 
  86.     </FONT>
  87.     </TD>
  88.     </TR>
  89.     </TABLE>
  90.     <BR><BR><BR>
  91.     <TABLE CELLPADDING=10 CELLSPACING=10 BORDER=0 WIDTH="100%">
  92.     <TR>
  93.     <TD>
  94.     <FONT FACE="Verdana,Helvetica"> 
  95.     <B>System Bullet points:</B>
  96.     <UL>
  97.     <LI> Totally automated publishing of database and spreadsheet data using a dial-up Internet connection.
  98.     <LI> The database does not need to be stored on the web server.
  99.     <LI> No specialist knowledge is required by web site maintainer.
  100.     <LI> Zero administration overhead- Just set the times/days when you
  101.     want to update your web site from your database and forget it!
  102.     </UL>
  103.     </FONT>
  104.     </TD>
  105.     </TR>
  106.     </TABLE>
  107.     <CENTER>
  108.     <FONT FACE="Helvetica">
  109.     <BR><BR>
  110.     <I>Web site design by:</I><BR>
  111.     <A HREF="http://www.gd-ind.com">GLOBAL DATA INDUSTRIES</A>
  112.     </CENTER>
  113.     </FONT>
  114.     </BODY>
  115.     </HTML>
  116. }
  117.  
  118.  
  119. &msgbox("Finished!",iconinformation)
  120. &cls
  121. &print("Demo website HTML generation complete. Click the HTML button to see the results.")
  122. &print
  123. &print
  124.  
  125. # END OF SCRIPT
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134. ##########################################################
  135. # SUBROUTINES
  136.  
  137.  
  138.  
  139.  
  140. ##########################################################
  141. # subroutine jobcategory generates the category pages
  142. # that are linked to from the top-level page 
  143.  
  144. &defsub("jobcategory")
  145. {
  146.  
  147.     # the html file name for each of the job categories is generated
  148.     # by combining the word "cat" with the row number of the job category in
  149.     # the database. since the last &sql function called was to fetch data
  150.     # from the jobs table, we put a [-1] at the end of the variable name
  151.     # ?rownumber? to indicate that it belongs to the previous &sql function's
  152.     # returned data.
  153.  
  154.     &html("cat?rownumber[-1]?.html")
  155.     {
  156.         <HTML>
  157.         <HEAD>
  158.         <TITLE>Jobs List</TITLE>
  159.         </HEAD>
  160.         <BODY BACKGROUND="wwbg1.gif" LINK=BLACK VLINK=BLACK ALINK=WHITE>
  161.         <FONT FACE="Verdana,Helvetica">
  162.         <TABLE WIDTH="80%" CELLSPACING=10 BORDER=0>
  163.         <TR>
  164.         <TD><IMG SRC="wwbullet1.gif"></TD>
  165.         <TD>
  166.         <FONT SIZE="+3" FACE="Verdana,Helvetica">
  167.         ?JobCategory[-1]?
  168.         </FONT>
  169.         </TD>
  170.         </TR>
  171.         </TABLE>
  172.         <UL><UL>
  173.  
  174.         # if there are jobs under this category, loop through each
  175.         # record creating a job description page (handled by
  176.         # subroutine "jobcontent") and a link from this page
  177.  
  178.  
  179.         &foreachrow
  180.         {
  181.             # generate the link to the job content file
  182.             <LI><A HREF="jfile?rownumber[-1]?n?rownumber?.html" onMouseover="window.status='View Job (?JobTitle?) details.';return true">?JobTitle?</A><BR>
  183.  
  184.             # followed by the file to link to
  185.             # (created by subroutine jobcontent)
  186.             &jobcontent
  187.         }
  188.  
  189.         # the code between the  characters following the &else() function
  190.         # will be executed if the &getdata() function failed to find any
  191.         # data.
  192.  
  193.         &else
  194.         {
  195.             <P>Sorry, there are no jobs under this category.
  196.         }
  197.    
  198.         </UL></UL>
  199.         </FONT>
  200.         </BODY>
  201.         </HTML>
  202.     }
  203. }
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212. ##########################################################
  213. # subroutine jobcontent generates the job content pages
  214. # that are linked to from the job category pages
  215.  
  216. &defsub("jobcontent")
  217. {
  218.     # the filename for the job content file is generated by combining
  219.     # the rownumber of the job category (?rownumber[-1]?) with the
  220.     # rownumber of the job.
  221.     # note the 'n' placed between the two rownumber variables, this is
  222.     # required to ensure a unique filename for the page. (think about it... #;-) )
  223.  
  224.     &html("jfile?rownumber[-1]?n?rownumber?.html")
  225.     {
  226.         <HTML>
  227.         <HEAD>
  228.         <TITLE>Job Description</TITLE>
  229.         </HEAD>
  230.         <BODY BACKGROUND="wwbg1.gif">
  231.         <TABLE WIDTH="80%" CELLSPACING=10 BORDER=0>
  232.         <TR>
  233.         <TD><IMG SRC="wwbullet1.gif"></TD>
  234.         <TD>
  235.         <FONT SIZE="+2" FACE="Verdana,Helvetica">
  236.         ?JobTitle?
  237.         </FONT>
  238.         </TD>
  239.         </TR>
  240.         </TABLE>
  241.         <CENTER>
  242.         <TABLE WIDTH="90%" CELLSPACING=10 BORDER=0>
  243.         <TR>
  244.         <TD>
  245.         <FONT FACE="Verdana,Helvetica"SIZE="+1">Job ref: ?JobNo?</FONT>
  246.         <TT>
  247.         <FONT SIZE="+1"><P>?JobDesc?</FONT>
  248.         </TT>
  249.         </TD>
  250.         </TR>
  251.         </TABLE>
  252.         </CENTER>
  253.         </BODY>
  254.         </HTML>
  255.     }
  256. }
  257.  
  258.  
  259.  
  260.  
  261.